home *** CD-ROM | disk | FTP | other *** search
/ Cre@te Online 2000 December / Cre@teOnline CD05.iso / MacSoft / XML ConsoleMax.sea / XML ConsoleMax / Required / esc.jar / com / extensibility / xa / AggregateAttributeDecl.class (.txt) < prev    next >
Encoding:
Java Class File  |  2000-06-30  |  9.2 KB  |  337 lines

  1. package com.extensibility.xa;
  2.  
  3. import com.extensibility.app.UI;
  4. import com.extensibility.util.Debug;
  5. import com.extensibility.xml.AttributeDeclaration;
  6. import com.extensibility.xml.BaseDeclaration;
  7. import com.extensibility.xml.DTDUtilities;
  8. import com.extensibility.xml.InternalPEDeclaration;
  9. import com.extensibility.xml.ParserException;
  10. import com.extensibility.xml.SchemaIntf;
  11. import com.extensibility.xml.URI;
  12. import com.extensibility.xml.dt.DataType;
  13. import java.util.Enumeration;
  14. import java.util.Hashtable;
  15. import java.util.Vector;
  16.  
  17. public class AggregateAttributeDecl extends BaseDeclaration implements Cloneable {
  18.    Vector kids = new Vector();
  19.    AttributeDeclaration globalAttr;
  20.  
  21.    public AggregateAttributeDecl(AttributeDeclaration var1) {
  22.       super(((BaseDeclaration)var1).getName());
  23.       this.addAttribute(var1);
  24.    }
  25.  
  26.    public String getClassName() {
  27.       return "com.extensibility.xml.AggregateAttributeDecl";
  28.    }
  29.  
  30.    public void addAttribute(AttributeDeclaration var1) {
  31.       this.kids.addElement(var1);
  32.       if (var1.isGlobal()) {
  33.          this.globalAttr = var1;
  34.       }
  35.  
  36.    }
  37.  
  38.    public void removeAttribute(AttributeDeclaration var1) {
  39.       this.kids.removeElement(var1);
  40.       if (this.globalAttr == var1) {
  41.          this.globalAttr = null;
  42.       }
  43.  
  44.    }
  45.  
  46.    AttributeDeclaration getGlobal() {
  47.       return this.globalAttr;
  48.    }
  49.  
  50.    public AttributeDeclaration remove(String var1) {
  51.       AttributeDeclaration var3 = null;
  52.  
  53.       int var2;
  54.       for(var2 = this.kids.size() - 1; var2 >= 0; --var2) {
  55.          var3 = (AttributeDeclaration)this.kids.elementAt(var2);
  56.          if (var3.getOwner().getName().equals(var1)) {
  57.             break;
  58.          }
  59.       }
  60.  
  61.       if (var2 < 0) {
  62.          return null;
  63.       } else {
  64.          this.removeAttribute(var3);
  65.          return var3;
  66.       }
  67.    }
  68.  
  69.    public String getFirstError() {
  70.       Enumeration var1 = this.getAttributes();
  71.  
  72.       while(var1.hasMoreElements()) {
  73.          AttributeDeclaration var2 = (AttributeDeclaration)var1.nextElement();
  74.          String var3 = ((BaseDeclaration)var2).getFirstError();
  75.          if (var3 != null) {
  76.             if (this.isShared()) {
  77.                return String.valueOf(String.valueOf(((BaseDeclaration)var2).getName()).concat(String.valueOf(" : "))).concat(String.valueOf(var3));
  78.             }
  79.  
  80.             return var3;
  81.          }
  82.       }
  83.  
  84.       return null;
  85.    }
  86.  
  87.    public Enumeration getAttributes() {
  88.       return this.kids.elements();
  89.    }
  90.  
  91.    public AttributeDeclaration getIndAttribute(int var1) {
  92.       return (AttributeDeclaration)this.kids.elementAt(var1);
  93.    }
  94.  
  95.    public int getAttributesSize() {
  96.       return this.kids.size();
  97.    }
  98.  
  99.    public Object clone() {
  100.       AggregateAttributeDecl var1 = null;
  101.  
  102.       try {
  103.          var1 = (AggregateAttributeDecl)super.clone();
  104.       } catch (CloneNotSupportedException var3) {
  105.          Debug.assert("Problem cloning AggregateAttributeDecl.", var3);
  106.       }
  107.  
  108.       var1.kids = new Vector();
  109.       Enumeration var2 = this.kids.elements();
  110.  
  111.       while(var2.hasMoreElements()) {
  112.          var1.kids.addElement(((AttributeDeclaration)var2.nextElement()).clone());
  113.       }
  114.  
  115.       return var1;
  116.    }
  117.  
  118.    public AggregateAttributeDecl copyOf() {
  119.       AggregateAttributeDecl var1 = null;
  120.  
  121.       try {
  122.          var1 = (AggregateAttributeDecl)super.clone();
  123.       } catch (CloneNotSupportedException var3) {
  124.          Debug.assert("Problem cloning AggregateAttributeDecl.", var3);
  125.       }
  126.  
  127.       var1.kids = new Vector();
  128.  
  129.       for(int var2 = 0; var2 < this.kids.size(); ++var2) {
  130.          var1.kids.addElement(this.kids.elementAt(var2));
  131.       }
  132.  
  133.       return var1;
  134.    }
  135.  
  136.    private void DoToEach(Operation var1) {
  137.       for(int var2 = 0; var2 < this.kids.size(); ++var2) {
  138.          var1.performOperation((AttributeDeclaration)this.kids.elementAt(var2));
  139.       }
  140.  
  141.    }
  142.  
  143.    public boolean contains(AttributeDeclaration var1) {
  144.       return this.kids.indexOf(var1) >= 0;
  145.    }
  146.  
  147.    public boolean contains(AttributeDeclaration.Owner var1) {
  148.       for(int var2 = 0; var2 < this.kids.size(); ++var2) {
  149.          if (var1.equals(this.getIndAttribute(var2).getOwner())) {
  150.             return true;
  151.          }
  152.       }
  153.  
  154.       return false;
  155.    }
  156.  
  157.    public void resetOwner() {
  158.       this.DoToEach(new 1((AggregateAttributeDecl)null));
  159.    }
  160.  
  161.    public void setOwner(SchemaDoc var1, String var2) {
  162.       this.DoToEach(new 2(var1, var2, (AggregateAttributeDecl)null));
  163.    }
  164.  
  165.    boolean nullEquals(Object var1, Object var2) {
  166.       if (var1 == null) {
  167.          return var2 == null;
  168.       } else {
  169.          return var2 == null ? false : var1.equals(var2);
  170.       }
  171.    }
  172.  
  173.    boolean nullEquals(Vector var1, Vector var2) {
  174.       if (!this.nullEquals((Object)var1, (Object)var2)) {
  175.          return false;
  176.       } else if (var1 == null) {
  177.          return true;
  178.       } else if (var1.size() != var2.size()) {
  179.          return false;
  180.       } else {
  181.          for(int var3 = 0; var3 < var1.size(); ++var3) {
  182.             if (!var1.elementAt(var3).equals(var2.elementAt(var3))) {
  183.                return false;
  184.             }
  185.          }
  186.  
  187.          return true;
  188.       }
  189.    }
  190.  
  191.    public void setDataType(DataType var1) {
  192.       this.DoToEach(new 3(var1, this));
  193.    }
  194.  
  195.    public void setRequired(boolean var1) {
  196.       this.DoToEach(new 4(var1, (AggregateAttributeDecl)null));
  197.    }
  198.  
  199.    public void setOptions(String var1) {
  200.       this.DoToEach(new 5(var1, this));
  201.    }
  202.  
  203.    public void setChoices(Vector var1) {
  204.       this.DoToEach(new 6(var1, this));
  205.    }
  206.  
  207.    public void setChoices(String var1) {
  208.       try {
  209.          Vector var2;
  210.          if (var1.indexOf(",") >= 0) {
  211.             var2 = DTDUtilities.parseNameList(var1, ',');
  212.          } else if (var1.indexOf("|") > 0) {
  213.             var2 = DTDUtilities.parseNameList(var1, '|');
  214.          } else {
  215.             var2 = DTDUtilities.parseNameList(var1, ' ');
  216.          }
  217.  
  218.          this.setChoices(var2);
  219.       } catch (ParserException var3) {
  220.          Debug.assert(var3);
  221.       }
  222.  
  223.    }
  224.  
  225.    public void setName(SchemaDoc var1, String var2) {
  226.       this.DoToEach(new 7(var1, var2, (AggregateAttributeDecl)null));
  227.    }
  228.  
  229.    public void putMetaProp(String var1, String var2) {
  230.       this.DoToEach(new 8(var1, var2, (AggregateAttributeDecl)null));
  231.    }
  232.  
  233.    public void appendMetaProp(String var1, String var2) {
  234.       this.DoToEach(new 9(var1, var2, (AggregateAttributeDecl)null));
  235.    }
  236.  
  237.    public Object getMetaProp(String var1) {
  238.       return this.getFirst().getMetaProp(var1);
  239.    }
  240.  
  241.    public void removeMetaProp(String var1) {
  242.       this.DoToEach(new 10(var1, (AggregateAttributeDecl)null));
  243.    }
  244.  
  245.    public String getMetaPropAsString(String var1) {
  246.       return this.getFirst().getMetaPropAsString(var1);
  247.    }
  248.  
  249.    public void putMetaPropList(String var1, String var2) {
  250.       this.DoToEach(new 11(var1, var2, (AggregateAttributeDecl)null));
  251.    }
  252.  
  253.    public void putMetaPropAttrs(String var1, Hashtable var2) {
  254.       this.DoToEach(new 12(var1, var2, (AggregateAttributeDecl)null));
  255.    }
  256.  
  257.    public void setDefault(String var1) {
  258.       this.DoToEach(new 13(var1, (AggregateAttributeDecl)null));
  259.    }
  260.  
  261.    public AttributeDeclaration getFirst() {
  262.       return this.kids.size() > 0 ? (AttributeDeclaration)this.kids.firstElement() : null;
  263.    }
  264.  
  265.    public String getOwnerName() {
  266.       return !this.isShared() && this.getFirst() != null ? String.valueOf(this.getFirst().getOwner() instanceof InternalPEDeclaration ? "%" : "").concat(String.valueOf(this.getFirst().getOwner().getName())) : UI.getString("attr.shared", Integer.toString(this.kids.size()));
  267.    }
  268.  
  269.    public AttributeDeclaration.Owner getOwner() {
  270.       return this.getFirst() != null ? this.getFirst().getOwner() : null;
  271.    }
  272.  
  273.    public String getName() {
  274.       return this.getFirst() != null ? this.getFirst().getName() : new String("");
  275.    }
  276.  
  277.    public URI getURI() {
  278.       return this.getFirst() != null ? this.getFirst().getURI() : null;
  279.    }
  280.  
  281.    public DataType getDataType() {
  282.       return this.getFirst() != null ? this.getFirst().getDataType() : null;
  283.    }
  284.  
  285.    public boolean getRequired() {
  286.       return this.getFirst() != null ? this.getFirst().getRequired() : false;
  287.    }
  288.  
  289.    public String getTypeForDisplay(SchemaIntf var1) {
  290.       return this.getFirst() != null ? this.getFirst().getTypeForDisplay(var1) : new String("");
  291.    }
  292.  
  293.    public String getCommentsAsString(String var1, String var2) {
  294.       return this.getFirst() != null ? this.getFirst().getCommentsAsString(var1, var2) : new String("");
  295.    }
  296.  
  297.    public Vector getChoices() {
  298.       return this.getFirst() != null ? this.getFirst().getChoices() : new Vector();
  299.    }
  300.  
  301.    public String getOptions() {
  302.       return this.getFirst() != null ? this.getFirst().getOptions() : "";
  303.    }
  304.  
  305.    public String getDefault() {
  306.       return this.getFirst() != null ? this.getFirst().getDefault() : new String("");
  307.    }
  308.  
  309.    public boolean isShared() {
  310.       return this.kids.size() > 1;
  311.    }
  312.  
  313.    public boolean isEnumeration() {
  314.       return this.getFirst() != null ? this.getFirst().isEnumeration() : false;
  315.    }
  316.  
  317.    public boolean isNotation() {
  318.       return this.getFirst() != null ? this.getFirst().isNotation() : false;
  319.    }
  320.  
  321.    public boolean equals(AttributeDeclaration var1) {
  322.       return this.getFirst() != null ? this.getFirst().canAggregateWith(var1) : false;
  323.    }
  324.  
  325.    public int compareTo(AttributeDeclaration var1) {
  326.       return this.getFirst() != null ? this.getFirst().compareAttrTo(var1) : 1;
  327.    }
  328.  
  329.    public String getSource() {
  330.       return this.getFirst() != null ? this.getFirst().getSource() : new String("");
  331.    }
  332.  
  333.    public String toString() {
  334.       return this.getFirst() != null ? this.getFirst().getSource() : new String("");
  335.    }
  336. }
  337.